/*
PearReview - The peer review assistant.
Copyright (C) 2009  Dimitrij Pankratz, Anton Musichin
http://www.pearreview.com, info@pearreview.com

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

package com.pearreview.ui.slidebox;

import java.awt.BorderLayout;

import javax.swing.Action;
import javax.swing.GroupLayout;
import javax.swing.JPanel;
import javax.swing.LayoutStyle;

import com.pearreview.ui.FormLabel;
import com.pearreview.application.Messages;
import com.pearreview.util.review.Attendee;

public class AttendeeSlideBox extends SlideBox<Attendee> {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -3988984907683860266L;

	public AttendeeSlideBox(Attendee attendee, Action delete, Action edit) {
		super(attendee, delete, edit);
		slidedHeight = 100;
	}
	
	@Override
	protected String getCaption() {
    	return Messages.getString("PearReview.Moderator.attendees.name") + ": " 
    			+ element.getName();
    }
    
	@Override
    protected void initContent(JPanel containerBottom) {

		FormLabel attendeeNameLabel = new FormLabel(Messages.getString(
				"PearReview.Moderator.attendees.name"));
		FormLabel attendeeName = new FormLabel(element.getName());
		FormLabel attendeeContactLabel = new FormLabel(Messages.getString(
				"PearReview.Moderator.attendees.contact"));
		FormLabel attendeeContact = new FormLabel(element.getContact());
		FormLabel attendeeRoleLabel = new FormLabel(Messages.getString(
				"PearReview.Moderator.attendees.role"));
		FormLabel attendeeRole = new FormLabel();
		
		switch (element.getRole()) {
		case Moderator:
			attendeeRole.setText(Messages.getString(
					"PearReview.review.modarator"));
			break;
		
		case Scribe:
			attendeeRole.setText(Messages.getString(
					"PearReview.review.scribe"));
			break;
			
		case Reviewer:
			attendeeRole.setText(Messages.getString(
					"PearReview.review.reviewer"));
			break;
			
		case Author:
			attendeeRole.setText(Messages.getString(
					"PearReview.review.author"));
			break;
			
		case Customer:
			attendeeRole.setText(Messages.getString(
					"PearReview.review.customer"));
			break;
		}
  
		
		containerBottom.setLayout(new BorderLayout());

		GroupLayout layout = new GroupLayout(containerBottom);
		
		containerBottom.setLayout(layout);
		layout.setHorizontalGroup(
			layout.createParallelGroup()
				.addGroup(layout.createSequentialGroup()
					.addContainerGap()
					.addGroup(layout.createParallelGroup()
						.addGroup(layout.createSequentialGroup()
							.addGroup(layout.createParallelGroup()
								.addGroup(GroupLayout.Alignment.TRAILING, 
										layout.createSequentialGroup()
									.addGroup(layout.createParallelGroup()
										.addComponent(attendeeNameLabel, 
												GroupLayout.Alignment.LEADING, 
												GroupLayout.DEFAULT_SIZE, 
												50, 
												GroupLayout.PREFERRED_SIZE)
										.addComponent(attendeeContactLabel,
												GroupLayout.Alignment.LEADING, 
												GroupLayout.DEFAULT_SIZE, 
												50, 
												GroupLayout.PREFERRED_SIZE)
										.addComponent(attendeeRoleLabel,
												GroupLayout.Alignment.LEADING, 
												GroupLayout.DEFAULT_SIZE, 50, 
												GroupLayout.PREFERRED_SIZE))
									.addGap(57, 57, 57)
									.addGroup(layout.createParallelGroup(
											GroupLayout.Alignment.TRAILING)
										.addComponent(attendeeRole, 
												GroupLayout.Alignment.LEADING, 
												10, 
												GroupLayout.PREFERRED_SIZE, 
												GroupLayout.PREFERRED_SIZE)
										.addComponent(attendeeContact, 
												GroupLayout.Alignment.LEADING, 
												10, GroupLayout.PREFERRED_SIZE, 
												GroupLayout.PREFERRED_SIZE)
										.addComponent(attendeeName, 
												GroupLayout.Alignment.LEADING, 
												10, 
												GroupLayout.PREFERRED_SIZE, 
												GroupLayout.PREFERRED_SIZE))
									.addGap(10, 10, 10))))))
								
		);
		layout.setVerticalGroup(
			layout.createParallelGroup()
				.addGroup(layout.createSequentialGroup()
					.addContainerGap()
					.addGroup(layout.createParallelGroup(
							GroupLayout.Alignment.BASELINE)
						.addComponent(attendeeNameLabel)
						.addComponent(attendeeName, 
								GroupLayout.PREFERRED_SIZE, 
								GroupLayout.DEFAULT_SIZE, 
								GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
					.addGroup(layout.createParallelGroup()
						.addComponent(attendeeContactLabel)
						.addComponent(attendeeContact, 
								GroupLayout.PREFERRED_SIZE, 
								GroupLayout.DEFAULT_SIZE, 
								GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
					.addGroup(layout.createParallelGroup()
						.addComponent(attendeeRoleLabel)
						.addComponent(attendeeRole, 
								GroupLayout.PREFERRED_SIZE, 
								GroupLayout.DEFAULT_SIZE, 
								GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED))
		);
    }
}